Page({
    data: {
      orderStatusMap: {
        1: '待付款',
        2: '已取消',
        3: '待收货',
        4: '已完成'
      },
      statusDesc: {
        1: '剩余支付时间 29:59',
        3: '包裹正在快马加鞭赶路中',
        4: '交易成功，感谢您的支持'
      },
      orderData: {
        orderNo: '20230815123456',
        status: 1,
        createTime: '2023-08-15 14:30:00',
        paymentTime: '',
        totalPrice: 356.00,
        freight: 12.00,
        discount: 20.00,
        paymentAmount: 348.00,
        address: {
          name: '张三',
          phone: '13800138000',
          detail: '广东省广州市天河区珠江新城华夏路1号'
        },
        goods: [
          {
            id: 1,
            thumb: '/images/goods1.jpg',
            title: '阳朔漓江竹筏漂流体验票',
            spec: '成人票 x2',
            price: 168.00,
            quantity: 2
          },
          {
            id: 2,
            thumb: '/images/goods2.jpg',
            title: '印象刘三姐演出门票',
            spec: 'VIP区 C排',
            price: 220.00,
            quantity: 1
          }
        ]
      }
    },
  
    onLoad(options) {
      // 从服务器获取订单数据
      this.getOrderDetail(options.orderId);
    },
  
    // 获取订单详情
    getOrderDetail(orderId) {
      wx.showLoading({ title: '加载中' });
      wx.request({
        url: `https://api.example.com/orders/${orderId}`,
        success: (res) => {
          this.setData({ orderData: res.data });
        },
        complete: wx.hideLoading
      });
    },
  
    // 处理支付
    handlePayment() {
      wx.requestPayment({
        timeStamp: '',
        nonceStr: '',
        package: '',
        signType: 'MD5',
        paySign: '',
        success: () => {
          this.getOrderDetail(this.data.orderData.id);
        }
      });
    },
  
    // 取消订单
    cancelOrder() {
      wx.showModal({
        title: '确认取消订单',
        content: '确定要取消该订单吗？',
        success: (res) => {
          if (res.confirm) {
            wx.request({
              url: `https://api.example.com/orders/${this.data.orderData.id}/cancel`,
              success: () => {
                this.getOrderDetail(this.data.orderData.id);
              }
            });
          }
        }
      });
    },
  
    // 查看物流
    viewLogistics() {
      wx.navigateTo({
        url: `/pages/logistics/logistics?orderNo=${this.data.orderData.orderNo}`
      });
    }
  });